#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main(){
	int x=0,y=0,z=0;
	char ch,name[30],ty[2];
	printf("命令模式为wc.exe [参数] [文件名]:\n");
	printf("请输入要输出的类型参数（-c为字符数，-w为单词数，-s为句子数）:\n");
	scanf("%s",ty);
	printf("请输入文件名：\n");
    scanf("%s",name);
	FILE*fp=fopen(name,"r");
    if(fp==NULL){
        printf("打开文件失败\n");
    }
	while((ch=getc(fp))!=EOF){
		if(ch==' '){
				y++;
				x=x-1;
				
		}
		else if((ch=='.')||(ch=='!')||(ch=='?')){
				z++;
				y++;
					
		}
        else if((ch==',')||(ch==':')||(ch==';')){
				y++;
					
		}
		
		x++;
	}
	if(ty[1]=='c'){
		printf("字符=%d\n",x);
	}
	if(ty[1]=='w'){
		printf("单词=%d\n",y);
	}
	if(ty[1]=='s'){
		printf("句子=%d\n",z);
	}
	fclose(fp);
    system("pause");
    return 0;
}